//表单回填
    var data=common.getLocalData('H5-agentInfo');
    if(!data){
        window.location.href="login.html";
    }else {
        var agentId=data.id;
        var token=common.getToken();
        if(agentId && token){
            var url=common.globalHost+common.getAgentDetailPort;
            var $businessCardInput=$("#businessCard");
            var $frontPhoto=$("#frontPhoto");
            var $backPhoto=$("#backPhoto");
            var $uploadBusinessCard=$("#esheyi-upload-businessCard");
            var $uploadFrontPhoto=$("#esheyi-upload-frontPhoto");
            var $uploadBackPhoto=$("#esheyi-upload-backPhoto");
            $.post(url,{id:data.id,token:token},function(resData){
                if(typeof resData=="string"){
                    resData=JSON.parse(resData);
                }
                if(resData.code!=0){
                    window.location.href='login.html';
                }
                var data=resData.res.data;
                $(".gma-back").html(!data || $.isEmptyObject(data) || data.noPassCause==="" || data.noPassCause===undefined?"":data.noPassCause.split("\\r\\n").join("&nbsp;&nbsp;"));
                initForm($("#form"),data);
                $(".upload-box").find('input[type="file"]').remove();
                var businessCard=new registerUpload($uploadBusinessCard,{
                    agentId:agentId,
                    fileType:"businessCard",
                    token:token,
                    uploadSuccess:function (resFile) {
                        // businessCard.uploadNotice.removeClass("failed").addClass("success").html("上传成功");
                        businessCard.uploadNotice.html("上传成功").show().delay(1000).hide(0);
                        // resFile=resFile.indexOf('http')>-1?resFile:common.imageHost+resFile;
                        $businessCardInput.val(resFile);
                    },
                    uploadFail:function (data) {
                        // businessCard.uploadNotice.removeClass("success").addClass("failed").html("上传失败,"+data.res.msg);
                        businessCard.uploadNotice.html("上传失败,"+data.res.msg).show().delay(1000).hide(0);
                    },
                    deleteImage:function () {
                        $businessCardInput.val("");
                    }
                },data.businessCard);
                var frontPhoto=new registerUpload($uploadFrontPhoto,{
                   agentId:agentId,
                   fileType:"frontPhoto",
                   token:token,
                   uploadSuccess:function (resFile) {
                        frontPhoto.uploadNotice.html("上传成功").show().delay(1000).hide(0);
                       // frontPhoto.uploadNotice.removeClass("failed").addClass("success").html("上传成功");
                       // resFile=resFile.indexOf('http')>-1?resFile:common.imageHost+resFile;
                       $frontPhoto.val(resFile);
                   },
                   uploadFail:function (data) {
                       frontPhoto.uploadNotice.html("上传失败,"+data.res.msg).show().delay(1000).hide(0);
                       // frontPhoto.uploadNotice.removeClass("success").addClass("failed").html("上传失败,"+data.res.msg);
                   },
                   deleteImage:function () {
                       $frontPhoto.val("");
                   }
                },data.frontPhoto);
                var backPhoto=new registerUpload($uploadBackPhoto,{
                    agentId:agentId,
                    fileType:"backPhoto",
                    token:token,
                    uploadSuccess:function (resFile) {
                        backPhoto.uploadNotice.html("上传成功").show().delay(1000).hide(0);
                        // backPhoto.uploadNotice.removeClass("failed").addClass("success").html("上传成功");
                        // resFile=resFile.indexOf('http')>-1?resFile:common.imageHost+resFile;
                        $backPhoto.val(resFile);
                    },
                    uploadFail:function (data) {
                        backPhoto.uploadNotice.html("上传失败,"+data.res.msg).show().delay(1000).hide(0);
                        // backPhoto.uploadNotice.removeClass("success").addClass("failed").html("上传失败,"+data.res.msg);
                    },
                    deleteImage:function () {
                        $backPhoto.val("");
                    }
                },data.backPhoto);
            });
        }else{
            window.location.href='login.html';
        }

    };
    var initForm=function(form,obj){
    var $form=$(form);
    $.each(obj,function(key,val){
        $form.find('input[name="'+key+'"]').val($("#transHidden").html(val).html());
    });
};
//模糊搜索
var storePanel=$('#store-list');
var storeNameInput=$('#store');
var storeListPort=common.getStoreListPort;
var companyPanel=$('#company-list');
var companyNameInput=$('#company');
var companyListPort=common.getCompanyListPort;
utils.searchCompanyName({listPanel:storePanel,upIdKey:"companyId",companyNameInput:storeNameInput,searchIdInput:$("#storeId"),companyListPort:storeListPort});
utils.searchCompanyName({listPanel:companyPanel,sonInput:$("#store"),sonIdKey:"storeId",companyNameInput:companyNameInput,searchIdInput:$("#companyId"),companyListPort:companyListPort});
//提交
var url = common.globalHost + common.registerMorePort;
var sendData={};
var $agentId=$('#agentId');
var agentId=common.getLocalData('H5-agentInfo').id;
baseInfoForm.submit.off('tap').on('tap',function(e){
	//给隐藏域添加agentId
	$agentId.val(agentId);
	var $this=$(this);
    var checkCase=$this.hasClass("act-ago");
    var backPhotoResult=baseInfoForm.uploadImg({targetSelector:baseInfoForm.backPhoto,noticeMsg:'身份证背面'});
    var frontPhotoResult=baseInfoForm.uploadImg({targetSelector:baseInfoForm.frontPhoto,noticeMsg:'身份证前面'});
    var businessCardResult=baseInfoForm.uploadImg({targetSelector:baseInfoForm.businessCard,noticeMsg:'工牌'});
    var IdCardResult=baseInfoForm.testIdCard({targetSelector:baseInfoForm.IdCard,noticeMsg:'身份证号码',length:18});
    var agentNameResult=baseInfoForm.testText({targetSelector:baseInfoForm.agentName,noticeMsg:'姓名'});
    var storeResult=baseInfoForm.testText({targetSelector:baseInfoForm.store,noticeMsg:'门店全称'});
    var companyResult=baseInfoForm.testText({targetSelector:baseInfoForm.company,noticeMsg:'公司名字'});
    sendData=common.getSendDataByForm(baseInfoForm.form);
    if(!!checkCase&&!!agentNameResult&&!!IdCardResult&&!!businessCardResult&&!!frontPhotoResult&&!!backPhotoResult&&!!storeResult&&!!companyResult){
    	 $this.removeClass("act-ago").addClass("acted-yet");
    	baseInfoForm.formPost({
    		url:url,
    		sendData:sendData,
    		resSuccess:function (data) {
                actedStyle(); 
                baseInfoForm.initForm(baseInfoForm.form); 
                window.location.href='registerAuth.html';
            },
            resFailed:function (data) {
                actAgoStyle();
            }
    	})
    }else{
    	console.log("不准发送ajax");
    }
    e.preventDefault();
    return false;
});
function actedStyle () {
    baseInfoForm.submit.removeClass("act-ago").addClass("acted-yet");
}
function actAgoStyle () {
    baseInfoForm.submit.removeClass("acted-yet").addClass("act-ago");
}